package com.xuecheng.content.api;

import com.xuecheng.content.mapper.TeachplanMapper;
import com.xuecheng.content.model.dto.SaveTeachPlanDto;
import com.xuecheng.content.model.dto.TeachPlanDto;
import com.xuecheng.content.service.TeachPlanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value = "课程计划接口",tags = "课程计划编辑接口")
@RestController
public class TeachPlanController {

    @Autowired
    private TeachPlanService teachPlanService;
    /**
     * 查询课程计划
     */
    @ApiOperation("查询课程计划树形接口")
    @GetMapping("/teachplan/{courseId}/tree-nodes")
    public List<TeachPlanDto> getTreeNodes(@PathVariable("courseId") Long courseId){
        List<TeachPlanDto> teachPlanDtoList = teachPlanService.selectTreeNodes(courseId);
        return teachPlanDtoList;
    }
    @ApiOperation("课程计划修改或添加")
    @PostMapping("/teachplan")
    public void saveTeachPlan(@RequestBody SaveTeachPlanDto saveTeachPlanDto){
        teachPlanService.saveTeachPlan(saveTeachPlanDto);
    }
    @ApiOperation("课程计划删除")
    @DeleteMapping("/teachplan/{id}")
    public void deleteTeachPlan(@PathVariable("id")Long id){
        boolean flag = teachPlanService.deleteTeachPlan(id);
    }
    @ApiOperation("课程移动")
    @PostMapping("/teachplan/{move}/{id}")
    public void moveTeachPlan(@PathVariable("move")String move,@PathVariable("id")Long id){
        teachPlanService.moveTeachPlan(move,id);
    }

}
